|
|
|
|
|
|
|
Figure 14.1
A simple surface. |
|
|
|
|
|
|
|
|
planes, pyramids, and bowls. They do not include objects like spheres, cubes, and tetrahedrons that have more than one Y value corresponding to the same X and Z coordinates. |
|
|
|
|
|
|
|
|
The grid data structures described in the next few sections let you manage many kinds of simple surfaces, including those for which you are working with incomplete data. |
|
|
|
|
|
|
|
|
The simplest way to store surface data is in a two-dimensional array. For each point (X, Z) in the area defined for the surface, the (X, Z) entry in the array gives the Y coordinate of the corresponding point on the surface. |
|
|
|
|
|
|
|
|
Drawing this kind of surface is easy. Simply draw the three-dimensional line segments connecting points on the surface that have adjacent X or Z values. The following Visual Basic code fragment shows how you could draw the line segments, assuming the data values are stored in the two-dimensional array Data. |
|
|
|
 |
|
|
|
|
Dim x As Integer
Dim z As Integer
' Draw the segments parallel to the X axis. For z = zmin To zmax
For x = xmin + 1 To xmax ' Draw the 3-D line connecting the points
' (x - 1, Data(x - 1, z), z) and
' (x, Data(x, z), z).
: Next x
Next z
' Draw the segments parallel to the Z axis. For x = xmin To xmax
For z = zmin + 1 To zmax |
|
|
|
|
|